package cn.exlu.coco.core.utils;

public class SqlUtil {
    public static String addLike(String str){
        if(StringUtil.isNullOrBlank(str)){
            return str;
        }
        return "%"+escapeSql(str) + "%";
    }
    
    
    /**
     * SQL特殊字符转义
     * @param str
     * @return
     */
    private static String escapeSql(String str){
         str = str.replace("\\", "\\\\");
         str = str.replace("%", "\\%");
         str = str.replace("_", "\\_");
         return str;
     }
}
